home *** CD-ROM | disk | FTP | other *** search
- // tdate.cpp: Test the Date class
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "date.h"
-
- main()
- {
- Date d1, d2, *result;
- int nargs;
-
- // Read in two dates - assume 1st precedes 2nd
- fputs("Enter a date, MM/DD/YY> ",stderr);
- nargs = scanf("%d/%d/%d%*c", &d1.month,
- &d1.day, &d1.year);
- if (nargs != 3)
- return EXIT_FAILURE;
-
- fputs("Enter a later date, MM/DD/YY> ",stderr);
- nargs = scanf("%d/%d/%d%*c", &d2.month,
- &d2.day, &d2.year);
- if (nargs != 3)
- return EXIT_FAILURE;
-
- // Compute interval in years, months, and days
- result = d1.interval(d2);
- printf("years: %d, months: %d, days: %d\n",
- result->year, result->month, result->day);
- return EXIT_SUCCESS;
- }
-
- /* Sample Execution:
- Enter a date, MM/DD/YY> 10/1/51
- Enter a later date, MM/DD/YY> 11/14/92
- years: 41, months: 1, days: 13
- */
-
-
-